//
//  NavigationControllerBase.swift
//  DataStructure
//
//  Created by kys-20 on 2019/8/27.
//  Copyright © 2019 kys-20. All rights reserved.
//

import Foundation
import UIKit
class NavigationControllerBase: UIViewController {
    
    private let backButtonWH = UIButton()
    override func viewDidLoad() {
        super.viewDidLoad()
        setUpButton()

    }
    
    func setUpButton() {
        backButtonWH.frame = CGRect(x: 0, y: 0, width: 20, height: 20)
        backButtonWH.setTitle("返回", for: .normal)
        backButtonWH.setTitleColor(UIColor.black, for: .normal)
        backButtonWH.setTitleColor(UIColor.green, for: .highlighted)
        backButtonWH.addTarget(self, action: #selector(backButtonAction), for: .touchUpInside)
        let navigationBackButton = UIBarButtonItem(customView: backButtonWH)
        self.navigationItem.leftBarButtonItems = [ navigationBackButton]
        
    }
    @objc func backButtonAction() {
        navigationController?.popViewController(animated: false)
//        self.dismiss(animated: false, completion: nil)
    }
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
          self.view.endEditing(true)
       
    }
}
